package com.service.impl;

import com.entity.Admin;
import com.mapper.UserMapper;
import com.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author ri.yang
 * @Since 2016/1/9.
 */
@Service
public class UserServiceImpl implements IUserService {
    @Resource
    private UserMapper userMapper;
    public Admin isValid(String username, String password) {
        if (username==null||"".equals(username.trim())){
            throw new RuntimeException("用户名不存在");
        }
        if (password==null||"".equals(password.trim())){
            throw new RuntimeException("密码不正确");
        }
        Admin admin=userMapper.findByUsernameAndPwd(username, password);
        if (admin==null){
            throw new RuntimeException("用户名或密码 不正确");
        }
        return admin;

    }
}
